package com.ruoyi.web.controller.system;

import com.aliyun.oss.OSS;
import com.aliyun.oss.model.CannedAccessControlList;
import com.aliyun.oss.model.ObjectMetadata;
import com.aliyun.oss.model.PutObjectRequest;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.web.controller.config.OssConfig;
import com.ruoyi.web.controller.util.OSSFileUtil;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;


/**
 * @author : Xuzhaobo
 * @date : 2025-02-14 19:21
 * @description :
 **/






/**
 * Author: Z.H.Z
 * Date: 2025/2/12 9:12
 */
@RestController
@RequestMapping("/file")
public class uploadController {

    private final OSSFileUtil ossFileUtil;

    public uploadController(OSSFileUtil ossFileUtil) {
        this.ossFileUtil = ossFileUtil;
    }

    @PostMapping("/upload")
    public AjaxResult upload(MultipartFile file) throws IOException {
        String url = ossFileUtil.uploadFile(file);
        return AjaxResult.success(url);
    }

}


